package com.yxw.blog.conf.exception;

import com.yxw.blog.bean.response.ResponseCode;
import com.yxw.blog.bean.response.StandardResponse;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.io.IOException;

/**
 * @author yexinwei
 * 全局异常统一处理
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(IOException.class)
    public StandardResponse IOException(IOException e){
        return new StandardResponse(ResponseCode.FILE_FAILED,null);
    }


    @ExceptionHandler(BlogException.class)
    public StandardResponse blogException(BlogException blogException){
        return new StandardResponse(blogException.getCode(),blogException.getMsg(),null);
    }

}
